import React, { useEffect } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { getChannel } from '../../store/actions/channel'

// 加载频道的数据（把频道的数据存储到 Redux），但凡对 Redux 的操作就是那 4 个文件
export default function Channel() {
  const dispatch = useDispatch()
  const { list } = useSelector((state) => state.channel)
  useEffect(() => {
    dispatch(getChannel())
  }, [dispatch])
  return (
    <ul className='catagtory'>
      {list.map((item) => (
        <li key={item.id} className='select'>
          {item.name}
        </li>
      ))}
    </ul>
  )
}
